import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import '../node_modules/jquery/dist/jquery'
import './plugins/axios'
import store from './store'


// 按需导入vant
import { Popup, ShareSheet } from 'vant';
import { Swipe, SwipeItem } from 'vant';
import { Sidebar, SidebarItem } from 'vant';
import { Tab, Tabs } from 'vant';
import { Grid, GridItem } from 'vant';

Vue.use(Popup);
Vue.use(ShareSheet);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Sidebar);
Vue.use(SidebarItem);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Grid);
Vue.use(GridItem);

Vue.config.productionTip = false

// 懒加载
import VueLazyload from 'vue-lazyload'
// 配置项
Vue.use(VueLazyload, {
    error: require('./other/loadingerr.png'),
    loading: require('./other/loading.png')
})

Vue.directive('focus', {
    inserted(el, binding, vnode) {
        // 聚焦元素
        el.focus()
    }
})

// Vue.prototype.resetSetItem = function(key, newVal) {
//     if (key === 'songchange' || key === 'songimgchange') {
//         // 创建一个StorageEvent事件
//         var newStorageEvent = document.createEvent('StorageEvent');
//         const storage = {
//             setItem: function(k, val) {
//                 sessionStorage.setItem(k, val);
//                 // 初始化创建的事件
//                 newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);
//                 // 派发对象
//                 window.dispatchEvent(newStorageEvent)
//             }
//         }
//         return storage.setItem(key, newVal);
//     }
// }

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')